# -*- coding: utf-8 -*-
# -----------------------
# @Time ： 2021/6/24 9:32 上午
# @Author ： liyi03
# @File ：iosAppLogin.py
# @IDE ：PyCharm
# -----------------------
from public.configer import appLogin_path, BUNDLE_ID, home_page_nine_grid_swipe_path
from public.driver import Driver
from public.keyWordAction import KeyWord
from utils.handleYaml import YamlHandler


class MedIosAPP(Driver):

    def login(self):
        self.action(YamlHandler(appLogin_path).get_yaml_data())

    def start_app(self):
        self.d.app_start(BUNDLE_ID)

    def set_home_page_nine_grid_swipe_coordinate(self):
        """
        设置首页九宫格坐标
        :return:
        """
        while 1:
            if KeyWord().value("我的患者").value_.exists:
                x1, y1, w1, h1 = KeyWord().value("我的患者").value_.bounds
                x2, y2, w2, h2 = KeyWord().value("药房").value_.bounds
                YamlHandler(home_page_nine_grid_swipe_path).write_yaml({"x1":int(x1),"y1":int(y1),"x2":int(x2),"y2":int(y2)})
                print("----------------设置首页九宫格坐标成功----------------")
                break




if __name__ == '__main__':
    MedIosAPP().set_home_page_nine_grid_swipe_coordinate()